#include "Win32Frame.h"
#include "InnerMethod.h"

#define IDT_SENDMESSAGE		(7000 + 1)
#define IDT_POSTMESSAGE		(7000 + 2)

LRESULT OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	_CenterWindow(hWnd);

	SetTimer(hWnd, IDT_SENDMESSAGE, 2100, NULL);
	SetTimer(hWnd, IDT_POSTMESSAGE, 700, NULL);

	return 0;
}

LRESULT OnPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hDC = BeginPaint(hWnd, &ps);
	
	const TCHAR* szInfo	= _T("Hello, Win32 App");
	RECT rtWnd;
	GetClientRect(hWnd, &rtWnd);
	SetBkMode(hDC, TRANSPARENT);
	SetTextColor(hDC, RGB(200, 100, 200));
	DrawText(hDC, szInfo, -1, &rtWnd, DT_SINGLELINE|DT_VCENTER|DT_CENTER);

	EndPaint(hWnd, &ps);

	return 0;
}

LRESULT OnTimer(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	switch (wParam)
	{
		case IDT_SENDMESSAGE:	
		{
			SendMessage(hWnd, 0XFFFC, 0, 0);
			break;
		}
		case IDT_POSTMESSAGE:
		{		
			PostMessage(hWnd, 0XFFFE, 0, 0);
			break;
		}
	}

	return 0;
}

LRESULT OnDestroy(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	KillTimer(hWnd, IDT_SENDMESSAGE);
	KillTimer(hWnd, IDT_POSTMESSAGE);

	PostQuitMessage(0);

	return 0;
}

LRESULT OnSendMsg(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	SetWindowText(hWnd, _T("SendMsg"));

	return 0;
}

LRESULT OnPostMsg(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	SetWindowText(hWnd, _T("PostMsg"));

	return 0;
}




































